//
//  SmallViewController.m
//  ProjectForA
//
//  Created by apple on 14/11/20.
//  Copyright (c) 2014年 hmengwei. All rights reserved.
//

#import "SmallViewController.h"
#import "SmallCollectionViewCell.h"

@interface SmallViewController ()<UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>

@end

@implementation SmallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self createCollectionView];
}

- (void)createCollectionView
{
    //布局
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    [layout setItemSize:CGSizeMake(self.view.frame.size.width / 3.4, self.view.frame.size.width / 3.4)];
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);

    self.collect = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 113) collectionViewLayout:layout];
    [_collect setBackgroundColor:[UIColor whiteColor]];
    _collect.dataSource = self;
    _collect.delegate = self;
    [_collect registerClass:[SmallCollectionViewCell class] forCellWithReuseIdentifier:@"small"];
    [self.view addSubview:_collect];
    [_collect release];
    [layout release];
}

//items
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 9;
    
}

//重用池
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SmallCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"small" forIndexPath:indexPath];
//    NSMutableDictionary *bigdic = [_MainArr objectAtIndex:indexPath.section];
//    NSArray *arr = [bigdic objectForKey:@"data"];
//    NSMutableDictionary *dic = [arr objectAtIndex:indexPath.item];
//    NSString *cover_s = [dic objectForKey:@"cover_s"];
//    [cell.aImage setImageWithURL:[NSURL URLWithString:cover_s]];

    return cell;
}



//跳转
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
